<template>
    <el-dialog :visible.sync="dialogVisible" :title="title" width="500px" @close="onClose">
        <center>
            <img :src="src" />
        </center>
        <div slot="footer" class="dialog-footer">
            <el-button @click="onClose">取 消</el-button>
        </div>
    </el-dialog>
</template>

<script>
import { getQRCode } from '@/api/sysNuoInvoice'

export default {
    data() {
        return {
            dialogVisible: false,
            title: '二维码认证',
            id: '',
            src: ''
        }
    },
    methods: {
        init() {
            getQRCode().then(res => {
                if (res.code === 20000) {
                    this.id = res.data
                    this.src = "/api/anon/sysNuoInvoice/download?id=" + this.id
                }
            })
        },
        onShow() {
            this.init()
            this.dialogVisible = true
        },
        onClose() {
            this.dialogVisible = false
        }
    }
}
</script>

<style scoped>
</style>
